import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      // name: 'home'  有子路由时，name就不需要了
      component: () => import('@/views/layout/indexView.vue'),
      redirect: '/home', // 重定向
      // 底部的tabbar封装，相当于是二级路由
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/home/indexView.vue')
        },
        {
          path: '/cart',
          name: 'cart',
          component: () => import('@/views/cart/indexView.vue')
        },
        {
          path: '/order',
          name: 'order',
          component: () => import('@/views/order/indexView.vue')
        },
        {
          path: '/mine',
          name: 'mine',
          component: () => import('@/views/mine/indexView.vue')
        },
      ]
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('@/views/about/indexView.vue')
    },
    {
      path: '/detail',
      name: 'detail',
      component: () => import('@/views/detail/indexView.vue')
    }
  ]
})

export default router
